package kbs.scm
{
    import flash.utils.getDefinitionByName;

    public class StaticMethodFunction extends PrimitiveFunction
    {
        public function StaticMethodFunction(cname:String, mname:String)
        {
            m_cname = cname;
            m_mname = mname;
        }

        override public function scmapply(alist:AList, env:Env):Base
        {
            var myc:Class = getDefinitionByName(m_cname) as Class;
            var argc:int = alist.length();
            var a:Array = [];
            for (var i:int = 0; i<argc; i++) {
                a.push(toObject(alist.get(i), env));
            }

            var myret:Object = myc[m_mname].apply(env, a);
            return toBase(myret);
        }

        override public function pprint():String
        {
            return m_cname+"::"+m_mname;
        }
        private var m_cname:String, m_mname:String;
    }
}
